import axios from 'axios'
import querystring  from 'querystring'

//封装get方法
export function get(url,params={}){
    return axios({
        url,
        params,
        method:'get'
    })
}

//封装post方法
export function post(url,params={},isFile=false){
    let data = null 
    if(isFile){
        data = new FormData()
        for(let i in params){
            data.append(i,params[i])
        }
    }else{
        data = querystring.stringify(params)
    }

    return axios({
        url,
        method:'post',
        data
    })
}